﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Hangjing.Common;
using Hangjing.SQLServerDAL;
using Hangjing.Model;
using System.Text;

/// <summary>
/// 显示所有商家在地图上
/// </summary>
public partial class qy_54tss_Admin_ajax_getallshops : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Points dal = new Points();
        string where = " IsDelete = 0 and Star = 1 and InUse = 'Y' and delflag = 0 ";
        int cid = HjNetHelper.GetQueryInt("cid", 0);
        if (cid > 0)
        {
            where += " and cityid = " + cid + "";
        }
        where = new RightsTool().getShopWhere(where);

        IList<PointsInfo> list = dal.getShopsBycityid( where);
        StringBuilder shoplistjson = new StringBuilder();

        shoplistjson.Append("[");

        foreach (var info in list)
        {
            shoplistjson.Append("{\"TogoName\":\"" + info.Name + "\"");
            shoplistjson.Append(",\"Comm\":\"" + info.Comm + "\"");
            shoplistjson.Append(",\"Unid\":\"" + info.Unid + "\"");
            shoplistjson.Append(",\"Address\":\"" + info.Address + "\"");


            shoplistjson.Append(",\"Lat\":\"" + info.Lat + "\"");
            shoplistjson.Append(",\"Lng\":\"" + info.Lng + "\"");

            shoplistjson.Append(",\"State\":\"" + (info.isonline == 1?"营业":"休息") + "\"},");
        }

        shoplistjson.Append("]");

        Response.Write(shoplistjson.ToString().Replace("},]", "}]"));
        Response.End();

    }
}
